const express = require('express')
const path = require('path')
const bodyParser = require('body-parser')
const server = express()

server.use(bodyParser.urlencoded())
server.use((req, res, next) => {
	res.header('Access-Control-Allow-Origin', '*')
	res.header('Access-Control-Allow-headers', 'Content-type, authorization')
	// authorization身份验证，响应头格式
	next();
})
server.get('/get', (req, res) => {
	if(req.query instanceof Object) {
		console.log(req.query.name);
	}
	res.send({name: '小丽丽',age: 18})
	// 
});
server.get('/get2', (req, res) => {
	res.send('2020')
})
server.post('/post', (req, res) => {
	res.send(req.body)
})
.listen(3000)
console.log('server is running...');
